<?php

class News
{
    private $titreNews;
    private $descriptionNews;
    private $linkNews;
    private $guidNews;
    private $pubDateNews;
    
    private $titleFeed;
    private $isRss;
    
    public function __construct($title, $isRss)
    {
        $this->titleFeed = (string)$title;
        $this->isRss = $isRss;
    }
    
    public function getTitleNews()
    {
        return ($this->titreNews);
    }
    
    public function getDescriptionNews()
    {
        return ($this->descriptionNews);
    }
    
    public function getLinkNews()
    {
        return ($this->linkNews);
    }
    
    public function getGuidNews()
    {
        return ($this->guidNews);
    }
    
    public function getPubDateNews()
    {
        return ($this->pubDateNews);
    }
    
    public function getTitleFeed()
    {
        return ($this->titleFeed);
    }
    
    public function affAll()
    {
        echo $this->titreNews . '<br />';
        echo $this->descriptionNews . '<br />';
        echo $this->linkNews . '<br />';
        echo $this->guidNews . '<br />';
        echo $this->pubDateNews . '<br />';
    }
    
    public function generateNews($newsItem)
    {
        if ($this->isRss)
        {
            $this->titreNews = $newsItem->title->__toString();
            $this->descriptionNews = $newsItem->description->__toString();
            $this->linkNews = $newsItem->link->__toString();
            $this->guidNews = $newsItem->link->__toString();
            $this->pubDateNews = $newsItem->pubDate->__toString();
        }
        else
        {
            $this->titreNews = $newsItem->title->__toString();
            $this->descriptionNews = $newsItem->summary->__toString();
            $this->linkNews = $newsItem->link->attributes()->href->__toString();
            $this->guidNews = $newsItem->id->__toString();
            $this->pubDateNews = $newsItem->updated->__toString();
        }
    }
}

?>